﻿//-----------------------------------------------------------------------
// <copyright file="DiagnosticsServiceClient.cs" company="CodePlex">
//     Copyright (c) Doug Holland, CodePlex. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace CodePlex.Diagnostics
{
    using System;

    using System.Collections;
    using System.Collections.Generic;

    using System.Reflection;

    using System.Security;
    using System.Security.Principal;

    using System.ServiceModel;

    using System.Xml;
    using System.Xml.Linq;

    using CodePlex.Diagnostics.Contracts;

    /// <summary>
    /// Implements the <see cref="T:IDiagnosticsService"/> interface and provides a Windows Communication Foundation (WCF) client to enable asynchronous service calls.
    /// </summary>
    public class DiagnosticsServiceClient : ClientBase<IDiagnosticsService>, IDiagnosticsService
    {
        #region public IAsyncResult BeginPublishException(ExceptionDataContract contract, Dictionary<string, string> dictionary, XElement element, IIdentityDataContract identity, AsyncCallback callback, object state);

        /// <summary>
        /// Begins an asynchronous operation that publishes the exception information contained within the specified <see cref="T:CodePlex.Diagnostics.Contracts.ExceptionDataContract"/> to the database.
        /// </summary>
        /// <param name="contract">The <see cref="T:CodePlex.Diagnostics.Contracts.ExceptionDataContract"/> containing the exception information to be published to the database.</param>
        /// <param name="dictionary">A <see cref="T:System.Collections.Generic.Dictionary`2"/> containing name value pairs associated with this exception.</param>
        /// <param name="element">A <see cref="T:System.Xml.Linq.XElement"/> representing an xml element to be associated with this exception.</param>
        /// <param name="identity">The <see cref="T:CodePlex.Diagnostics.Contracts.IIdentityDataContract"/> containing the identity information to be published to the database.</param>
        /// <param name="callback">An optional asynchronous callback, to be called when the asynchronous operation is complete. </param>
        /// <param name="state">A user-provided state object.</param>
        /// <returns>An <see cref="T:IAsyncResult"/> that represents the asynchronous operation, which could still be pending.</returns>
        public IAsyncResult BeginPublishException(ExceptionDataContract contract, Dictionary<string, string> dictionary, XElement element, IIdentityDataContract identity, AsyncCallback callback, object state)
        {
            return Channel.BeginPublishException(contract, dictionary, element, identity, callback, state);
        }

        #endregion

        #region public Guid EndPublishException(IAsyncResult result)

        /// <summary>
        /// Ends an asynchronous operation to publish an exception.
        /// </summary>
        /// <param name="result">The result of the asynchronous operation to publish an exception.</param>
        /// <returns>A <see cref="T:Guid"/> containing the publication Id of the exception published to the database.</returns>
        public Guid EndPublishException(IAsyncResult result)
        {
            return Channel.EndPublishException(result);
        }

        #endregion

        #region public IAsyncResult BeginLog(LogEntryDataContract contract, Dictionary<string, string> dictionary, XElement element, IIdentityDataContract identity, AsyncCallback callback, object state)

        /// <summary>
        /// Begins an asynchronous operation that writes the <see cref="T:System.String"/> using the configured logging provider.
        /// </summary>
        /// <param name="contract">The <see cref="T:CodePlex.Diagnostics.Contracts.LogEntryDataContract"/> containing the log entry information to be published to the database.</param>
        /// <param name="dictionary">A <see cref="T:System.Collections.Generic.Dictionary`2"/> containing name value pairs associated with this log entry.</param>
        /// <param name="element">A <see cref="T:System.Xml.Linq.XElement"/> representing an xml element to be associated with this log entry.</param>
        /// <param name="identity">The <see cref="T:CodePlex.Diagnostics.Contracts.IIdentityDataContract"/> containing the identity information to be published to the database.</param>
        /// <param name="callback">An optional asynchronous callback, to be called when the asynchronous operation is complete. </param>
        /// <param name="state">A user-provided state object.</param>
        /// <returns>An <see cref="T:IAsyncResult"/> that represents the asynchronous operation, which could still be pending.</returns>
        public IAsyncResult BeginLog(LogEntryDataContract contract, Dictionary<string, string> dictionary, XElement element, IIdentityDataContract identity, AsyncCallback callback, object state)
        {
            return Channel.BeginLog(contract, dictionary, element, identity, callback, state);
        }

        #endregion

        #region public Guid EndLog(IAsyncResult result)

        /// <summary>
        /// Ends an asynchronous operation to write the specified log entry to the database.
        /// </summary>
        /// <param name="result">The result of the asynchronous operation to write the specified log entry to the database.</param>
        /// <returns>A <see cref="T:Guid"/> containing the publication Id of the log entry written to the database.</returns>
        public Guid EndLog(IAsyncResult result)
        {
            return Channel.EndLog(result);
        }

        #endregion

        #region public IAsyncResult BeginUpdateProcessExitInformation(int processId, DateTime startTime, DateTime exitTime, int exitCode, AsyncCallback callback, object state)

        /// <summary>
        /// Begins an asynchronous operation to update process exit information.
        /// </summary>
        /// <param name="processId">The process Id representing the <see cref="T:System.Diagnostics.Process"/> for which details about how and when it exited should be published.</param>
        /// <param name="startTime">The process start time.</param>
        /// <param name="exitTime">The process exit time.</param>
        /// <param name="exitCode">The process exit code.</param>
        /// <param name="callback">An optional asynchronous callback, to be called when the asynchronous operation is complete. </param>
        /// <param name="state">A user-provided state object.</param>
        /// <returns>An <see cref="T:IAsyncResult"/> that represents the asynchronous operation, which could still be pending.</returns>
        public IAsyncResult BeginUpdateProcessExitInformation(int processId, DateTime startTime, DateTime exitTime, int exitCode, AsyncCallback callback, object state)
        {
            return Channel.BeginUpdateProcessExitInformation(processId, startTime, exitTime, exitCode, callback, state);
        }

        #endregion

        #region public void EndUpdateProcessExitInformation(IAsyncResult result)

        /// <summary>
        /// Ends an asynchronous operation to update process exit information.
        /// </summary>
        /// <param name="result">The result of the asynchronous operation to update process exit information.</param>
        public void EndUpdateProcessExitInformation(IAsyncResult result)
        {
            Channel.EndUpdateProcessExitInformation(result);
        }

        #endregion

        #region public IAsyncResult BeginRegisterTeamFoundationServer(TeamFoundationServerDataContract contract, AsyncCallback callback, object state)

        /// <summary>
        /// Begins an asynchronous operation to register the Team Foundation Server specified by the supplied <see cref="T:Uri"/> to the database.
        /// </summary>
        /// <param name="contract">The <see cref="T:CodePlex.Diagnostics.Contracts.TeamFoundationServerDataContract"/> representing the Team Foundation Server to be registered within the database.</param>
        /// <param name="callback">An optional asynchronous callback, to be called when the asynchronous operation is complete. </param>
        /// <param name="state">A user-provided state object.</param>
        /// <returns>An <see cref="T:IAsyncResult"/> that represents the asynchronous operation, which could still be pending.</returns>
        public IAsyncResult BeginRegisterTeamFoundationServer(TeamFoundationServerDataContract contract, AsyncCallback callback, object state)
        {
            return Channel.BeginRegisterTeamFoundationServer(contract, callback, state);
        }

        #endregion

        #region public void EndRegisterTeamFoundationServer(IAsyncResult result)

        /// <summary>
        /// Ends an asynchronous operation to register a Team Foundation Server to the database.
        /// </summary>
        /// <param name="result">The result of the asynchronous operation to update process exit information.</param>
        public void EndRegisterTeamFoundationServer(IAsyncResult result)
        {
            Channel.EndRegisterTeamFoundationServer(result);
        }

        #endregion
    }
}
